package com.empire.module.member.dal.mysql.user;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.empire.framework.mybatis.core.mapper.BaseMapperX;
import com.empire.module.member.dal.dataobject.user.DeptMemberDO;
import org.apache.ibatis.annotations.Mapper;

import java.util.Collection;
import java.util.List;

@Mapper
public interface DeptMemberMapper extends BaseMapperX<DeptMemberDO> {

    default List<DeptMemberDO> selectListByDeptId(Long deptId) {
        return selectList(DeptMemberDO::getDeptId, deptId);
    }

    default List<DeptMemberDO> selectListByMemberId(Long memberId) {
        return selectList(DeptMemberDO::getMemberId, memberId);
    }

    default void deleteListByDeptIdAndRoleIdIds(Long deptId, Collection<Long> memberIds) {
        delete(new LambdaQueryWrapper<DeptMemberDO>()
                .eq(DeptMemberDO::getDeptId, deptId)
                .in(DeptMemberDO::getMemberId, memberIds));
    }

    default void deleteListByDeptId(Long deptId) {
        delete(new LambdaQueryWrapper<DeptMemberDO>().eq(DeptMemberDO::getDeptId, deptId));
    }

    default void deleteListByMemberId(Long memberId) {
        delete(new LambdaQueryWrapper<DeptMemberDO>().eq(DeptMemberDO::getMemberId, memberId));
    }

}
